<?php

namespace App\Http\Middleware;

use App\Eloquent\User;
use Closure;
use Jenssegers\Agent\Agent;

class Mobile
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {		
    		$agent = new Agent();
    		if($agent->isMobile() || preg_match('/^(https|http):\/\/mobile.ibeibeili.com/', $request->root())){
    		  return redirect('https://mobile.ibeibeili.com/weixin/html/');
    		}
    			
             return $next($request);        //强制登陆
    }
}
